package org.dtrd.modules.evaluation.entity.bean.parq;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.dtrd.modules.evaluation.constant.Evaluation;
import org.dtrd.modules.evaluation.entity.po.DtrdEntEvaluationRdParq;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 
 * </p>
 *
 * @author xiao
 * @since 2022-08-15
 */
@Getter
@Setter
@ApiModel(value = "列表信息", description = "")
public class ParqListInfo {

    private Integer dataId;


    @ApiModelProperty("患者ID")
    private Integer patientId;


    @ApiModelProperty("选项答案一共7题，是为1，否为0")
    private List<Integer> answers;

    @ApiModelProperty("计算后的得分")
    private Integer score;

    @ApiModelProperty("返回评估结果")
    private String output;

    @ApiModelProperty("创建时间")
    private Date createTime;

    public ParqListInfo parseFromPo(DtrdEntEvaluationRdParq po) {
        this.dataId = po.getDataId();
        this.patientId = po.getPatientId();
        String input = po.getInput();
        String[] answerList = input.split(",");
        ArrayList<Integer> answers = new ArrayList<>(Evaluation.ProblemNum.PARQ.getNum());
        for (String s : answerList) {
            Integer answer = Integer.parseInt(s);
            answers.add(answer);
        }
        this.answers = answers;
        this.score = po.getScore();
        this.output = po.getOutput();
        this.createTime = po.getCreateTime();
        return this;
    }
}
